#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
use Text::CSV;
 
my $csv = Text::CSV->new({ binary => 1, auto_diag => 1 });
my $excel = Spreadsheet::WriteExcel->new('output.xls');
my $sheet = $excel->add_worksheet();
my $row = 0;
open my $fh, "<:encoding(utf8)", "input.csv" or die "Can't open 'input.csv': $!";
while (my $array_ref = $csv->getline($fh)) {
    my @fields = @$array_ref;
    $sheet->write($row, 0, \@fields); # 将整行写入Excel文件中的一行
    $row++;
}
close $fh;
